## API Report File for "@backstage/backend-app-api"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).

```ts
/// <reference types="node" />

import type { AppConfig } from '@backstage/config';
import { BackendFeature } from '@backstage/backend-plugin-api';
import { CacheClient } from '@backstage/backend-common';
import { Config } from '@backstage/config';
import { ConfigSchema } from '@backstage/config-loader';
import { CorsOptions } from 'cors';
import { DiscoveryService } from '@backstage/backend-plugin-api';
import { ErrorRequestHandler } from 'express';
import { Express as Express_2 } from 'express';
import { Format } from 'logform';
import { Handler } from 'express';
import { HelmetOptions } from 'helmet';
import * as http from 'http';
import { HttpRouterService } from '@backstage/backend-plugin-api';
import { HumanDuration } from '@backstage/types';
import { IdentityService } from '@backstage/backend-plugin-api';
import { JsonObject } from '@backstage/types';
import { LifecycleService } from '@backstage/backend-plugin-api';
import { LoadConfigOptionsRemote } from '@backstage/config-loader';
import { LoggerService } from '@backstage/backend-plugin-api';
import { PermissionsService } from '@backstage/backend-plugin-api';
import { PluginDatabaseManager } from '@backstage/backend-common';
import { RemoteConfigSourceOptions } from '@backstage/config-loader';
import { RequestHandler } from 'express';
import { RequestListener } from 'http';
import { RootConfigService } from '@backstage/backend-plugin-api';
import { RootHttpRouterService } from '@backstage/backend-plugin-api';
import { RootLifecycleService } from '@backstage/backend-plugin-api';
import { RootLoggerService } from '@backstage/backend-plugin-api';
import { SchedulerService } from '@backstage/backend-plugin-api';
import { ServiceFactory } from '@backstage/backend-plugin-api';
import { ServiceFactoryOrFunction } from '@backstage/backend-plugin-api';
import { TokenManagerService } from '@backstage/backend-plugin-api';
import { transport } from 'winston';
import { UrlReader } from '@backstage/backend-common';

// @public (undocumented)
export interface Backend {
  // (undocumented)
  add(
    feature:
      | BackendFeature
      | (() => BackendFeature)
      | Promise<{
          default: BackendFeature | (() => BackendFeature);
        }>,
  ): void;
  // (undocumented)
  start(): Promise<void>;
  // (undocumented)
  stop(): Promise<void>;
}

// @public (undocumented)
export const cacheServiceFactory: () => ServiceFactory<CacheClient, 'plugin'>;

// @public (undocumented)
export function createConfigSecretEnumerator(options: {
  logger: LoggerService;
  dir?: string;
  schema?: ConfigSchema;
}): Promise<(config: Config) => Iterable<string>>;

// @public
export function createHttpServer(
  listener: RequestListener,
  options: HttpServerOptions,
  deps: {
    logger: LoggerService;
  },
): Promise<ExtendedHttpServer>;

// @public
export function createLifecycleMiddleware(
  options: LifecycleMiddlewareOptions,
): RequestHandler;

// @public (undocumented)
export function createSpecializedBackend(
  options: CreateSpecializedBackendOptions,
): Backend;

// @public (undocumented)
export interface CreateSpecializedBackendOptions {
  // (undocumented)
  defaultServiceFactories: ServiceFactoryOrFunction[];
}

// @public (undocumented)
export const databaseServiceFactory: () => ServiceFactory<
  PluginDatabaseManager,
  'plugin'
>;

// @public
export class DefaultRootHttpRouter implements RootHttpRouterService {
  // (undocumented)
  static create(options?: DefaultRootHttpRouterOptions): DefaultRootHttpRouter;
  // (undocumented)
  handler(): Handler;
  // (undocumented)
  use(path: string, handler: Handler): void;
}

// @public
export interface DefaultRootHttpRouterOptions {
  indexPath?: string | false;
}

// @public (undocumented)
export const discoveryServiceFactory: () => ServiceFactory<
  DiscoveryService,
  'plugin'
>;

// @public
export interface ExtendedHttpServer extends http.Server {
  // (undocumented)
  port(): number;
  // (undocumented)
  start(): Promise<void>;
  // (undocumented)
  stop(): Promise<void>;
}

// @public
export class HostDiscovery implements DiscoveryService {
  static fromConfig(
    config: Config,
    options?: {
      basePath?: string;
    },
  ): HostDiscovery;
  // (undocumented)
  getBaseUrl(pluginId: string): Promise<string>;
  // (undocumented)
  getExternalBaseUrl(pluginId: string): Promise<string>;
}

// @public (undocumented)
export interface HttpRouterFactoryOptions {
  getPath?(pluginId: string): string;
}

// @public (undocumented)
export const httpRouterServiceFactory: (
  options?: HttpRouterFactoryOptions | undefined,
) => ServiceFactory<HttpRouterService, 'plugin'>;

// @public
export type HttpServerCertificateOptions =
  | {
      type: 'pem';
      key: string;
      cert: string;
    }
  | {
      type: 'generated';
      hostname: string;
    };

// @public
export type HttpServerOptions = {
  listen: {
    port: number;
    host: string;
  };
  https?: {
    certificate: HttpServerCertificateOptions;
  };
};

// @public
export type IdentityFactoryOptions = {
  issuer?: string;
  algorithms?: string[];
};

// @public (undocumented)
export const identityServiceFactory: (
  options?: IdentityFactoryOptions | undefined,
) => ServiceFactory<IdentityService, 'plugin'>;

// @public
export interface LifecycleMiddlewareOptions {
  // (undocumented)
  lifecycle: LifecycleService;
  startupRequestPauseTimeout?: HumanDuration;
}

// @public
export const lifecycleServiceFactory: () => ServiceFactory<
  LifecycleService,
  'plugin'
>;

// @public
export function loadBackendConfig(options: {
  remote?: LoadConfigOptionsRemote;
  argv: string[];
  additionalConfigs?: AppConfig[];
  watch?: boolean;
}): Promise<{
  config: Config;
}>;

// @public (undocumented)
export const loggerServiceFactory: () => ServiceFactory<
  LoggerService,
  'plugin'
>;

// @public
export class MiddlewareFactory {
  compression(): RequestHandler;
  cors(): RequestHandler;
  static create(options: MiddlewareFactoryOptions): MiddlewareFactory;
  error(options?: MiddlewareFactoryErrorOptions): ErrorRequestHandler;
  helmet(): RequestHandler;
  logging(): RequestHandler;
  notFound(): RequestHandler;
}

// @public
export interface MiddlewareFactoryErrorOptions {
  logAllErrors?: boolean;
  showStackTraces?: boolean;
}

// @public
export interface MiddlewareFactoryOptions {
  // (undocumented)
  config: RootConfigService;
  // (undocumented)
  logger: LoggerService;
}

// @public (undocumented)
export const permissionsServiceFactory: () => ServiceFactory<
  PermissionsService,
  'plugin'
>;

// @public
export function readCorsOptions(config?: Config): CorsOptions;

// @public
export function readHelmetOptions(config?: Config): HelmetOptions;

// @public
export function readHttpServerOptions(config?: Config): HttpServerOptions;

// @public (undocumented)
export interface RootConfigFactoryOptions {
  argv?: string[];
  remote?: Pick<RemoteConfigSourceOptions, 'reloadInterval'>;
}

// @public (undocumented)
export const rootConfigServiceFactory: (
  options?: RootConfigFactoryOptions | undefined,
) => ServiceFactory<RootConfigService, 'root'>;

// @public (undocumented)
export interface RootHttpRouterConfigureContext {
  // (undocumented)
  app: Express_2;
  // (undocumented)
  config: RootConfigService;
  // (undocumented)
  lifecycle: LifecycleService;
  // (undocumented)
  logger: LoggerService;
  // (undocumented)
  middleware: MiddlewareFactory;
  // (undocumented)
  routes: RequestHandler;
}

// @public (undocumented)
export type RootHttpRouterFactoryOptions = {
  indexPath?: string | false;
  configure?(context: RootHttpRouterConfigureContext): void;
};

// @public (undocumented)
export const rootHttpRouterServiceFactory: (
  options?: RootHttpRouterFactoryOptions | undefined,
) => ServiceFactory<RootHttpRouterService, 'root'>;

// @public
export const rootLifecycleServiceFactory: () => ServiceFactory<
  RootLifecycleService,
  'root'
>;

// @public (undocumented)
export const rootLoggerServiceFactory: () => ServiceFactory<
  RootLoggerService,
  'root'
>;

// @public (undocumented)
export const schedulerServiceFactory: () => ServiceFactory<
  SchedulerService,
  'plugin'
>;

// @public (undocumented)
export const tokenManagerServiceFactory: () => ServiceFactory<
  TokenManagerService,
  'plugin'
>;

// @public (undocumented)
export const urlReaderServiceFactory: () => ServiceFactory<UrlReader, 'plugin'>;

// @public
export class WinstonLogger implements RootLoggerService {
  // (undocumented)
  addRedactions(redactions: Iterable<string>): void;
  // (undocumented)
  child(meta: JsonObject): LoggerService;
  static colorFormat(): Format;
  static create(options: WinstonLoggerOptions): WinstonLogger;
  // (undocumented)
  debug(message: string, meta?: JsonObject): void;
  // (undocumented)
  error(message: string, meta?: JsonObject): void;
  // (undocumented)
  info(message: string, meta?: JsonObject): void;
  static redacter(): {
    format: Format;
    add: (redactions: Iterable<string>) => void;
  };
  // (undocumented)
  warn(message: string, meta?: JsonObject): void;
}

// @public (undocumented)
export interface WinstonLoggerOptions {
  // (undocumented)
  format: Format;
  // (undocumented)
  level: string;
  // (undocumented)
  meta?: JsonObject;
  // (undocumented)
  transports: transport[];
}
```
